<template>
	<view class="content" :style="getstyle()">
		<!-- 当设置tab-width,指定每个tab宽度时,则不使用flex布局,改用水平滑动 -->
		<swiper style="height:100%;margin-top: 0px;"  :current="tabIndex" @change="swiperChange">
			<swiper-item v-for="(tab,i) in tabs" :key="i">
			<view v-for="(tab,i) in datas" :key="i">
					<view class="Item">
						<view class="item-link item-content">
							<view class="item-inner">
								<view class="item-text">
									<view>{{tab.name}}</view>						
								</view>
							</view>
							<view class="item-inner">
								<view class="item-text"  v-for="(fileId,y) in tab.fields">
									<view v-if="fileId.widgetType=='file' && fileId.props.fileType=='image' && fileId.name=='产权证明'"
									 style="height: 200rpx;margin-top:80rpx !important;width: 48%;
									 margin-right: 48%;
									 float: left;">
										<view  :class="fileId.props.isRequired=='1'?'redispan':'noredispan'">{{fileId.name}}：</view>
										<view class="redspan" style="1rpx #f6f6f6 solid;">
											
											<image :src="getvalues(fileId)" class="item-icon" style="background-color: #f6f6f6;" 
											mode="" @tap="uploadimg(fileId)"></image>
										</view>		
									</view>
									<view v-if="fileId.widgetType=='file' && fileId.props.fileType=='image' && fileId.name!='产权证明'"
									 style="height: 200rpx;margin-top:80rpx !important;width: 48%;
									 float: left;">
										<view  :class="fileId.props.isRequired=='1'?'redispan':'noredispan'">{{fileId.name}}：</view>
										<view class="redspan" style="1rpx #f6f6f6 solid;">
											
											<image :src="getvalues(fileId)" class="item-icon" style="background-color: #f6f6f6;" 
											mode="" @tap="uploadimg(fileId)"></image>
										</view>		
									</view>
								</view>
								
								<view class="item-text"  v-for="fileId in tab.fields">
									<view v-if="fileId.widgetType!='file'">
										<view  class="ispan">{{fileId.name}}：</view>
										<view class="span">{{fileId.value}}</view>		
									</view>
									<view v-else-if="fileId.props.fileType!='image'">
										<view  class="ispan">{{fileId.name}}：</view>
										<view class="span">{{fileId.value}}</view>		
									</view>
								</view>
							</view>
							
						</view>
					</view>	
		
			</view>
		</swiper-item>
		</swiper>
	</view>
</template>

<script>
	import MescrollBody from "@/components/mescroll-uni/mescroll-body.vue"
	import MescrollUni from "@/components/mescroll-uni/mescroll-uni.vue"
	import AssetCentenr from "./assetcentenr.vue";
	import meassettabs from "@/components/me-asset-tabs/me-asset-tabs.vue";
	import uniSteps from '@/components/wangxiaohua--steps/index.vue';
	import jsQR from 'jsqr';
import { forEach } from "jszip";
	var self;
	export default {
		components: {
			MescrollBody,
			MescrollUni,
			AssetCentenr,
			meassettabs,
			uniSteps,
		},
		data() {
			return {
				height: "900px", // 需要固定swiper的高度
				tabs: [{
					name: '资产信息',
					code: ''
				}],
				tabIndex: 0, // 当前tab的下标
				Type: 1,
				srcstring: "../../static/images/icon-paizhao.png",
				stepslist: [],
				datas: [],
				mydata:{},
				map:{},
				documentid:"",
				imgfileIdList:[],

			}
		},
		computed: {
			
		},
		onBackPress(options) {
			// console.log(options);
			
			
			uni.setStorageSync('setStatusIndexFunc', 0);
			//uni.setStorageSync('scanmytype', "assetupload");
			//	uni.navigateTo({
			//		url: '../home/scan-stock',
			//		animationType: 'slide-in-left',
			//		animationDuration: 400
			//	});
			//	return true;
				//uni.setStorageSync('homebackDate', 0);
			//	uni.setStorageSync('setStatusIndexFunc', 0);
				//uni.navigateTo({
				//	url: '../home/Index',
				//	animationType: 'slide-in-left',
				//	animationDuration: 400
				//});
				//return true;
			
		},
		onNavigationBarButtonTap(){
			
			self=this;
			try{
				
				for(var i=0;i<self.imgfileIdList.length;i++){
					
					if(self.imgfileIdList[i].src.toString().indexOf("gdzc")==-1){
						uni.showToast({
						icon: 'none',
						title: self.imgfileIdList[i].name+"尚未上传照片"
						});
						return;
					}
				}
				
				
	
				self.mydata.convertData=self.datas;
				let mydata=
				{
				"id":self.map.documentDetailId,
				"assetInfo":{"other":{
					"wholeImage":"[{\"name\":\"微信图片_20240626162051.png\",\"type\":\"image/png\",\"size\":33944,\"status\":\"success\",\"realUrl\":\"gdzcfile/common/2024-06-26/696ba02858b4295b211c.png\",\"url\":\"gdzcfile/common/2024-06-26/696ba02858b4295b211c.png\"}]",
					"assetLabelImage":"[{\"name\":\"微信图片_20240626162051.png\",\"type\":\"image/png\",\"size\":33944,\"status\":\"success\",\"realUrl\":\"gdzcfile/common/2024-06-26/3f6ed00f1844614a75b9.png\",\"url\":\"gdzcfile/common/2024-06-26/3f6ed00f1844614a75b9.png\"}]",
					"snImage":"[{\"name\":\"微信图片_20240626162051.png\",\"type\":\"image/png\",\"size\":33944,\"status\":\"success\",\"realUrl\":\"gdzcfile/common/2024-06-26/8fe8f562aa4484baed6d.png\",\"url\":\"gdzcfile/common/2024-06-26/8fe8f562aa4484baed6d.png\"}]",
					"brandModelImage":"[{\"name\":\"微信图片_20240626162051.png\",\"type\":\"image/png\",\"size\":33944,\"status\":\"success\",\"realUrl\":\"gdzcfile/common/2024-06-26/46287ccfba9425a9e511.png\",\"url\":\"gdzcfile/common/2024-06-26/46287ccfba9425a9e511.png\"}]",
					"vinImage":"[{\"name\":\"微信图片_20240626162051.png\",\"type\":\"image/png\",\"size\":33944,\"status\":\"success\",\"realUrl\":\"gdzcfile/common/2024-06-26/46287ccfba9425a9e511.png\",\"url\":\"gdzcfile/common/2024-06-26/46287ccfba9425a9e511.png\"}]",
					"ownershipImage":"[{\"name\":\"微信图片_20240626162051.png\",\"type\":\"image/png\",\"size\":33944,\"status\":\"success\",\"realUrl\":\"gdzcfile/common/2024-06-26/46287ccfba9425a9e511.png\",\"url\":\"gdzcfile/common/2024-06-26/46287ccfba9425a9e511.png\"}]",
					"communityImage":"[{\"name\":\"微信图片_20240626162051.png\",\"type\":\"image/png\",\"size\":33944,\"status\":\"success\",\"realUrl\":\"gdzcfile/common/2024-06-26/46287ccfba9425a9e511.png\",\"url\":\"gdzcfile/common/2024-06-26/46287ccfba9425a9e511.png\"}]",
					//"assetAttachFiles":"[{\"name\":\"微信图片_20240626162051.png\",\"type\":\"image/png\",\"size\":33944,\"status\":\"success\",\"realUrl\":\"gdzcfile/common/2024-06-26/46287ccfba9425a9e511.png\",\"url\":\"gdzcfile/common/2024-06-26/46287ccfba9425a9e511.png\"}]",
					"doorNumberImage":"[{\"name\":\"微信图片_20240626162051.png\",\"type\":\"image/png\",\"size\":33944,\"status\":\"success\",\"realUrl\":\"gdzcfile/common/2024-06-26/46287ccfba9425a9e511.png\",\"url\":\"gdzcfile/common/2024-06-26/46287ccfba9425a9e511.png\"}]",
					},
					
					},
				};	
						//vinImage
						//ownershipImage
			
			let assetInfo_wholeImage= JSON.parse(mydata.assetInfo.other.wholeImage);
			if(assetInfo_wholeImage!=null){
				if(self.datas[0].fields.wholeImage!=null){
					let save_wholeImage= JSON.parse(self.datas[0].fields.wholeImage.value);
					if(save_wholeImage!=null){
						assetInfo_wholeImage[0].name=save_wholeImage[0].name;
						assetInfo_wholeImage[0].type=save_wholeImage[0].type;
						assetInfo_wholeImage[0].realUrl=save_wholeImage[0].realUrl;
						assetInfo_wholeImage[0].url=save_wholeImage[0].url;
						
						mydata.assetInfo.other.wholeImage=JSON.stringify(assetInfo_wholeImage);
					}
				}
			}
		
			let assetInfo_assetLabelImage= JSON.parse(mydata.assetInfo.other.assetLabelImage);
			if(assetInfo_assetLabelImage!=null){
				if(self.datas[0].fields.assetLabelImage!=null){
					let save_assetLabelImage= JSON.parse(self.datas[0].fields.assetLabelImage.value);
				if(assetInfo_assetLabelImage!=null){
					assetInfo_assetLabelImage[0].name=save_assetLabelImage[0].name;
					assetInfo_assetLabelImage[0].type=save_assetLabelImage[0].type;
					assetInfo_assetLabelImage[0].realUrl=save_assetLabelImage[0].realUrl;
					assetInfo_assetLabelImage[0].url=save_assetLabelImage[0].url;
					mydata.assetInfo.other.assetLabelImage=JSON.stringify(assetInfo_assetLabelImage);
					
					}
				}
			}
	
		
			console.log(JSON.parse(mydata.assetInfo.other.brandModelImage));
			let assetInfo_brandModelImage= JSON.parse(mydata.assetInfo.other.brandModelImage);
			if(self.datas[0].fields.brandModelImage!=null){
				
					let save_brandModelImage= JSON.parse(self.datas[0].fields.brandModelImage.value);
					if(save_brandModelImage!=null){
						assetInfo_brandModelImage[0].name=save_brandModelImage[0].name;
						assetInfo_brandModelImage[0].type=save_brandModelImage[0].type;
						assetInfo_brandModelImage[0].realUrl=save_brandModelImage[0].realUrl;
						assetInfo_brandModelImage[0].url=save_brandModelImage[0].url;
						mydata.assetInfo.other.brandModelImage=JSON.stringify(assetInfo_brandModelImage);
				}
			}
			
			
			console.log(1224);
			let assetInfo_snImage= JSON.parse(mydata.assetInfo.other.snImage);
			if(assetInfo_snImage!=null){
				if(self.datas[0].fields.snImage!=null){
					let save_snImage= JSON.parse(self.datas[0].fields.snImage.value);
				if(save_snImage!=null){
					assetInfo_snImage[0].name=save_snImage[0].name;
					assetInfo_snImage[0].type=save_snImage[0].type;
					assetInfo_snImage[0].realUrl=save_snImage[0].realUrl;
					assetInfo_snImage[0].url=save_snImage[0].url;
					mydata.assetInfo.other.snImage=JSON.stringify(assetInfo_snImage);
					}
				}
			}
			
			//vinImage
						//ownershipImage
			console.log(self.datas[0].fields.vinImage);
			let assetInfo_vinImage= JSON.parse(mydata.assetInfo.other.vinImage);
			if(assetInfo_vinImage!=null){
				if(self.datas[0].fields.vinImage!=null){
					let save_vinImage= JSON.parse(self.datas[0].fields.vinImage.value);
					if(save_vinImage!=null){
						assetInfo_vinImage[0].name=save_vinImage[0].name;
						assetInfo_vinImage[0].type=save_vinImage[0].type;
						assetInfo_vinImage[0].realUrl=save_vinImage[0].realUrl;
						assetInfo_vinImage[0].url=save_vinImage[0].url;
						mydata.assetInfo.other.vinImage=JSON.stringify(assetInfo_vinImage);
					}
				}
			}
			let assetInfo_ownershipImage= JSON.parse(mydata.assetInfo.other.ownershipImage);
			if(assetInfo_ownershipImage!=null){
				if(self.datas[0].fields.ownershipImage!=null){
					let save_ownershipImage= JSON.parse(self.datas[0].fields.ownershipImage.value);
					if(save_ownershipImage!=null){
						assetInfo_ownershipImage[0].name=save_ownershipImage[0].name;
						assetInfo_ownershipImage[0].type=save_ownershipImage[0].type;
						assetInfo_ownershipImage[0].realUrl=save_ownershipImage[0].realUrl;
						assetInfo_ownershipImage[0].url=save_ownershipImage[0].url;
						mydata.assetInfo.other.ownershipImage=JSON.stringify(assetInfo_ownershipImage);
					}
				}
			}
			
			let assetInfo_communityImage= JSON.parse(mydata.assetInfo.other.communityImage);
			if(assetInfo_communityImage!=null){
				if(self.datas[0].fields.communityImage!=null){
					let save_communityImage= JSON.parse(self.datas[0].fields.communityImage.value);
					if(save_communityImage!=null){
						assetInfo_communityImage[0].name=save_communityImage[0].name;
						assetInfo_communityImage[0].type=save_communityImage[0].type;
						assetInfo_communityImage[0].realUrl=save_communityImage[0].realUrl;
						assetInfo_communityImage[0].url=save_communityImage[0].url;
						mydata.assetInfo.other.communityImage=JSON.stringify(assetInfo_communityImage);
					}
				}
			}
			
			
			
			let assetInfo_doorNumberImage= JSON.parse(mydata.assetInfo.other.doorNumberImage);
			if(assetInfo_doorNumberImage!=null){
				if(self.datas[0].fields.doorNumberImage!=null){
					let save_doorNumberImage= JSON.parse(self.datas[0].fields.doorNumberImage.value);
					if(save_doorNumberImage!=null){
						assetInfo_doorNumberImage[0].name=save_doorNumberImage[0].name;
						assetInfo_doorNumberImage[0].type=save_doorNumberImage[0].type;
						assetInfo_doorNumberImage[0].realUrl=save_doorNumberImage[0].realUrl;
						assetInfo_doorNumberImage[0].url=save_doorNumberImage[0].url;
						mydata.assetInfo.other.doorNumberImage=JSON.stringify(assetInfo_doorNumberImage);
					}
				}
			}
			
			//console.log(mydata);
			//console.log(self.mydata);
			
			//return;
			this.request_tool({
				url:'/console/app/v1/document-detail/updateAssetInfo',
				type:'POST',
				data:mydata
			}).then(res => {	
				if(res.data.code==2000){
					console.log(res);
					//uni.showToast({
					//icon: 'none',
					//title: res.data.msg
					//});
					uni.setStorageSync('homebackDate', 0);
					uni.setStorageSync('setStatusIndexFunc', 0);
					
					uni.navigateTo({
						url: '../home/Index',
						animationType: 'slide-in-left',
						animationDuration: 400
					});
				}else{
					uni.showToast({
					icon: 'none',
					title: "保存错误"+JSON.stringify(res)
					});
				}
				
			}).catch(err => {
			  console.error(err);
			//  uni.showToast({
			//  icon: 'none',
			 // title: "提交失败"+err
			//  });
			});
			}catch (eee) {
				//模拟接口请求失败
				uni.showToast({
				icon: 'none',
				title: eee
				});
			}
		},
		methods: {
			getstyle(){
				if(this.tabIndex==0){
					return "background-color: #fff;height: 2000px;";
				}else{
					return "background-color: #fff;height: 100%;";
				}
			},
			innerclick(e) {
				self = this;
				if (self.newmodel.Groups[e.currentTarget.dataset.index].show == "1") {
					self.newmodel.Groups[e.currentTarget.dataset.index].show = "0";
				} else {
					self.newmodel.Groups[e.currentTarget.dataset.index].show = "1";
				}

			},
			// 轮播菜单
			swiperChange(e) {
				this.tabIndex = e.detail.current
			},			
			uploadimg(fileId) {
				console.log(fileId);
				self = this;
				
				// 只允许通过相机扫码
				uni.chooseImage({
					count: 1,
					sizeType: ['original', 'compressed'],
					sourceType: ['camera'],
					success: function(res) {
						// 预览图片
						console.log(res);
						this.images = res.tempFilePaths;
						const mysrc = res.tempFilePaths[0];
						console.log(mysrc);
						const tempFilePaths = res.tempFilePaths;
						if(fileId.name=="资产标签"){
							uni.showNavigationBarLoading(); //显示加载动画
							self.unloadjpg(fileId,mysrc,90);

							}else{
								
								uni.compressImage({
								      src: mysrc, // 图片路径
								      //quality: 80, // 压缩质量，范围为0 - 100，100为不压缩
									 quality: 50, //压缩比例  图片质量[10-100]
									//overwrite: true,
								      success: function (res3) {
								        // 获取压缩后的图片路径
										 console.log(res3)
								        var compressedFilePath = res3.tempFilePath
								        console.log('压缩后的图片路径：' + compressedFilePath)
										
										const header={
											'Content-Type':'application/json',
											Authorization: uni.getStorageSync("authorization")
										};
										
										uni.uploadFile({
										  url: uni.getStorageSync("localurl")+'/console/app/v1/fileOss/upload', // 你的上传API地址
										  filePath: compressedFilePath,
										  name: 'file',
											header: header, // 设置请求的 header
										  formData: {
										    // 其他要上传的参数
											file:{}
										  },
										  success: (uploadRes) => {
										    console.log('上传成功', uploadRes);
											let uploadResdata= JSON.parse(uploadRes.data);
											if(uploadResdata.code==2000){
												
												let value= JSON.parse(fileId.value);
												if(value==null){
													value=[{}];
													value[0].type="image/jpg";
													value[0].name=uploadResdata.data;
												}else{
													value[0].type="image/jpg";
													value[0].name=uploadResdata.data;
												}
												value[0].realUrl=uploadResdata.data;
												value[0].url=uploadResdata.data;
												fileId.value=JSON.stringify(value);
												let oriValue= JSON.parse(fileId.oriValue);
												if(oriValue==null){
													oriValue=[{}];
													oriValue[0].type="image/jpg";
													oriValue[0].name=uploadResdata.data;
												}else{
													oriValue[0].type="image/jpg";
													oriValue[0].name=uploadResdata.data;
												}
												oriValue[0].realUrl=uploadResdata.data;
												oriValue[0].url=uploadResdata.data;
												fileId.oriValue=JSON.stringify(oriValue);
												console.log(fileId);
											}else{
												uni.showToast({
													icon: 'none',
													title: uploadRes.data.msg
												});							
											}
										  },
										  fail: (uploadErr) => {
										    console.log('上传失败', uploadErr);
										  }
										});
										
										},
										fail: function (err) {
																  uni.hideNavigationBarLoading();
										  console.log('压缩失败：' + err)
										}
									});
								
								
							}
						
								
						 
						
						
					}
				});
			},
			
			unloadjpg(fileId,mysrc,size){
				self=this;
				uni.compressImage({
				      src: mysrc, // 图片路径
				      //quality: 80, // 压缩质量，范围为0 - 100，100为不压缩
					 quality: size, //压缩比例  图片质量[10-100]
					//overwrite: true,
				      success: function (res) {
				        // 获取压缩后的图片路径
						 console.log(res)
				        var compressedFilePath = res.tempFilePath
				        console.log('压缩后的图片路径：' + compressedFilePath)
						
						plus.barcode.scan(compressedFilePath, (type, result, file) => {
						       uni.hideNavigationBarLoading();
								console.log(result);
								console.log(self.mydata);
								let jg1=JSON.parse(result);
								if(jg1["唯一标识"]==undefined){
									// 识别失败
									uni.showModal({
									  title: '识别失败',
									  content:"图片内资产编码错误",
									  showCancel: false
									});
								}else{
									console.log(self.mydata.id);
									if(self.mydata.id==jg1["唯一标识"]){
										const header={
											'Content-Type':'application/json',
											Authorization: uni.getStorageSync("authorization")
										};
										
										uni.uploadFile({
										  url: uni.getStorageSync("localurl")+'/console/app/v1/fileOss/upload', // 你的上传API地址
										  filePath:compressedFilePath,
										  name: 'file',
											header: header, // 设置请求的 header
										  formData: {
										    // 其他要上传的参数
											file:{}
										  },
										  success: (uploadRes) => {
										    console.log('上传成功', uploadRes);
											let uploadResdata= JSON.parse(uploadRes.data);
											if(uploadResdata.code==2000){
												
												let value= JSON.parse(fileId.value);
												if(value==null){
													value=[{}];
													value[0].type="image/jpg";
													value[0].name=uploadResdata.data;
												}else{
													value[0].type="image/jpg";
													value[0].name=uploadResdata.data;
												}
												value[0].realUrl=uploadResdata.data;
												value[0].url=uploadResdata.data;
												fileId.value=JSON.stringify(value);
												let oriValue= JSON.parse(fileId.oriValue);
												if(oriValue==null){
													oriValue=[{}];
													oriValue[0].type="image/jpg";
													oriValue[0].name=uploadResdata.data;
												}else{
													oriValue[0].type="image/jpg";
													oriValue[0].name=uploadResdata.data;
												}
												oriValue[0].realUrl=uploadResdata.data;
												oriValue[0].url=uploadResdata.data;
												fileId.oriValue=JSON.stringify(oriValue);
												//uni.showModal({
												 // title: '提醒',
												//  content:"上传成功",
												//  showCancel: false
												//});
											}else{
												uni.showToast({
													icon: 'none',
													title: uploadRes.data.msg
												});							
											}
										  },
										  fail: (uploadErr) => {
										    console.log('上传失败', uploadErr);
										  }
										});
									}else{
										uni.hideNavigationBarLoading();
										// 识别失败
										uni.showModal({
										  title: '识别失败',
										  content:"图片内编码跟资产编码不匹配",
										  showCancel: false
										});
										
									}
								}
						      }, (error) => {
						        // 识别失败
								if(size>11){
									size=size-10;
									self.unloadjpg(fileId,mysrc,size);
								}else{
									uni.hideNavigationBarLoading();
									uni.showModal({
									  title: '识别失败',
									  content: "资产标签图片没有二维码信息",
									  showCancel: false
									});
								}
						      });
						
				      },
				      fail: function (err) {
						  uni.hideNavigationBarLoading();
				        console.log('压缩失败：' + err)
				      }
				    })
			}
			,
			getvalues(fileId){
				let value=JSON.parse(fileId.value);
				
				if(value==null){
					let flag=false;
					for(var i=0;i<this.imgfileIdList.length;i++){
						if(this.imgfileIdList[i].name==fileId.name){
							this.imgfileIdList[i].src="../../static/images/none.png";
							flag=true;
						}
					}
					if(flag==false){
						let imgitem={
							name:fileId.name,
							src: "../../static/images/none.png"
						}
						if(fileId.props.isRequired=="1"){
							this.imgfileIdList.push(imgitem);
						}
					}
					return "../../static/images/none.png";
				}else{
					let flag=false;
					for(var i=0;i<this.imgfileIdList.length;i++){
						if(this.imgfileIdList[i].name==fileId.name){
							this.imgfileIdList[i].src=value[0].realUrl;
							flag=true;
						}
					}
					if(flag==false){
						let imgitem={
							name:fileId.name,
							src: value[0].realUrl
						}
						if(fileId.props.isRequired=="1"){
							this.imgfileIdList.push(imgitem);
						}
					}
					//console.log('http://47.100.57.58:9000/'+value[0].realUrl);
					return uni.getStorageSync("localurlfileurl")+value[0].realUrl;
				}
			},
			 // 从图片中解析二维码
			   async decodeQRFromImage(imagePath) {
			      // 读取图片
			      const image = await uni.getImageInfo({
						src: imagePath
					});
			      // 将图片转换为二进制数据
				  console.log(image);
			      const base64Data = image[1];
				  console.log(Uint8Array.from(atob(base64Data), c => c.charCodeAt(0)));
			      // 使用jsQR解析二维码
			      const code = jsQR(
			        Uint8Array.from(atob(base64Data), c => c.charCodeAt(0)),
			        image.width,
			        image.height
			      );
			      // 如果找到二维码，返回解析结果，否则返回null
				  console.log(code);
			      //return code ? code.data : null;
			    },
			request_tool(options){
			 // 在这里可以对请求头进行一些设置
			 let baseUrl = uni.getStorageSync("localurl"); 
			 let userInfo = uni.getStorageSync("userInfo");
			 if (userInfo) {
			 	options.data['userLevelCode'] =JSON.parse(userInfo).levelCode;
			 	options.data['loginUserId'] = JSON.parse(userInfo).id;
			 }
			 let userDept = uni.getStorageSync("userDept");
			// console.log(userDept);
			 if (userDept) {
			 	options.data['loginUserDeptLevelCode'] = userDept.levelCode;
			 	options.data['loginUserDeptId'] = userDept.id;
			 }
			 let currentRole = uni.getStorageSync("userRoles");
			  //console.log(currentRole);
			 if (currentRole) {
			 	options.data['roleLevelCode'] = currentRole[0].levelCode;
			 	options.data['roleId'] = currentRole[0].id;
			 }
			 let userReadDeptIds = uni.getStorageSync("userReadDeptIds");
			 
			 if (userReadDeptIds) {
			 	options.data['deptIds'] =userReadDeptIds;
			 }
			  options.header = {
			      'Content-Type':'application/json',
			      Authorization: uni.getStorageSync("authorization")
			 }
			
			    return new Promise((resolve, reject) => {
			        uni.request({
			            url: baseUrl + options.url || '',
			            method: options.type || 'POST',
			            data: options.data || {},
			            header: options.header || {}      
			        }).then(data => {
			            let [err, res] = data;        
			            resolve(res);
			        }).catch(error => {
			            reject(error)
			        })
			    });
			}
			
			 
		},
		onLoad(options) {
			
			 
			// 需要固定swiper的高度
			//this.height = uni.getSystemInfoSync().windowHeight + 'px'
			//console.log(options.Id)
			uni.removeStorageSync("CurrAssetId");
			uni.removeStorageSync("CurrdocumentDetailId");
			uni.removeStorageSync("CurrdocumentId");
			this.Type = options.Type;
			this.documentid=options.documentId;
			uni.setStorageSync("CurrAssetId", options.Id);
			if (options.documentDetailId != undefined)
				uni.setStorageSync("CurrdocumentDetailId", options.documentDetailId);
				
			if (options.documentId != undefined)
				uni.setStorageSync("CurrdocumentId", options.documentId);
			if (options.documentDetailAssetId != undefined){
				uni.setStorageSync("CurrdocumentDetailAssetId", options.documentDetailAssetId);
			}
			if (options.documentDetailAssetId != undefined){
				//扫描上传
		
			
				this.request_tool({
					url:'/console/app/v1/document-detail/findByAssetId/'+options.documentDetailAssetId,
					type:'POST',
					data:{
					
				 }
				}).then(res => {
					if(res.data.code==2000){
						console.log(res);
						this.datas=res.data.data.convertData;
						this.mydata=res.data.data;
						this.map=res.data.map;
						
						
					}else{
						uni.showToast({
						icon: 'none',
						title: '请求失败'
						});
					}
					
				}).catch(err => {
				  console.error(err);
				});
			}else{
				//点击查看
				var AssetId = uni.getStorageSync("CurrAssetId");
				console.log(AssetId);
				///console/app/v1/asset/findById/{id}
				this.request_tool({
						url:'/console/app/v1/asset/findById/'+AssetId,
						type:'POST',
						data:{
						
					 }
					}).then(res => {
							console.log(res);
							if(res.data.code==2000){
								this.datas=res.data.data.convertData;
								console.log(this.datas);
							}else{
								uni.showToast({
									icon: 'none',
									title: res.data.msg
								});							
							}
						}).catch(err => {
					  console.error(err);
					  
					});
					
					this.request_tool({
							url:'/console/app/v1/asset-log/pageDataByAssetId',
							type:'POST',
							data:{
							"assetId":AssetId
						 }
						}).then(res => {
							console.log(res);
							if(res.data.code==2000){
								let alldata=[];
								for (var i = 0; i < res.data.data.records.length; i++) {
									let mydata= res.data.data.records[i];
									
									var datarow = {
										"操作日期":mydata["convertData"]["createTime"],
										"操作人":mydata["convertData"]["createUser"],
										"单据编号":mydata["convertData"]["documentCode"],
										"操作类型":mydata["convertData"]["processTypeId"],
										"处理内容":mydata["convertData"]["processContent"],
									};
									
									alldata.push(datarow);
								}
								console.log(alldata);
								self.stepslist = alldata;
							}else{
								uni.showToast({
									icon: 'none',
									title: res.data.msg
								});							
							}
							
						}).catch(err => {
					  console.error(err);
					  
					});
			}

		}
	}
</script>

<style>
	.item-icon {
		width: 100upx;
		height: 100upx;
	}
	.content {
		background-color: #edf1f4;
	}
	
	.Item {
		overflow: hidden;
		border-radius: 16rpx;
		background: #fff;
		margin-top: 10rpx;
	}
	
	.item-text .span {
		display: inline-block;
		width: 67%;
		float: right;
		
	}
	
	.item-text .ispan {
		font-style: normal;
		width: 30%;
		display: inline-block;
		color: #9E9CA5;
	}
	
	
	
	.item-content {
		padding-left: 0;
	}
	
	.item-title .ispan {
		font-size: 30rpx;
		width: auto;
		height: auto;
	}
	
	.item-title {
		font-size: 40rpx;
		color: #454545;
		width: 100%;
	}
	
	.item-title-row {
		background-image: none;
		padding-right: 0px;
	}
	
	.item-link .item-inner {
		padding-right: 0;
	}
	.item-text {
		font-size: 30rpx;
		color: #454545;
		margin: 20rpx 0;
		padding-left: 20rpx;
		line-height: 1.2;
	}
	
	.item-text .redispan {
		font-style: normal;
		width: 50%;
		display: inline-block;
		color: red;
	}
	.item-text .noredispan {
		font-style: normal;
		width: 50%;
		display: inline-block;
		color: #9E9CA5;
	}
	
	.item-text .redspan {
		display: inline-block;
		width: 50%;
		float: right;
		
	}
</style>
<canvas canvas-id="qrcodeCanvas" style="width: 300px; height: 300px; position: absolute; top: -10000px;"></canvas>